MySQL INSERT Statement

The INSERT statement is used to add records to the table.

Syntax 1 for INSERT statement

insert into table_name(column_1, column_2,column_3, ...) VALUES(value1,value2,value3, ...);

Example

insert into employee(name, age, role, location) values('Rayan', 26, 'Technical Lead', 'Canada');

Here we will be inserting the records to specific columns by mentioning the column name and its values.

Syntax 2 for INSERT statement

insert into table_name VALUES(value1,value2,value3, ...);

Example

insert into employee values('004','Rayan', 26, 'Technical Lead', 'Canada');

In the above query, we will add the values for all the columns of the table. Here the order of the values should be in same order as per the columns order in the table.

Executing the above query will add a new record to the employee table.

empno name age role location
001 Andrew 30 Manager India
002 Beslin 28 Business Analyst India
003 Joanna 23 Senior Developer USA
004 Rayan 26 Technical Lead Canada

Most Read